package top.healthylife.gateway.platform.br.api.check;

import org.springframework.stereotype.Service;
import top.healthylife.basics.utils.exception.BusinessException;
import top.healthylife.gateway.core.config.BaseConfig;
import top.healthylife.gateway.core.service.CheckSecretService;
import top.healthylife.gateway.platform.br.api.config.SystemConfig;
import top.healthylife.gateway.platform.br.api.external.po.AccountPo;
import top.healthylife.gateway.platform.br.api.utils.GetmeltingTokenUtils;

import java.util.List;

/**
 * @author : GaoZeXi
 * @date 2021/3/19 14:48
 */
@Service
public class CheckSecretServiceImpl implements CheckSecretService {
    @Override
    public void checkSecret(BaseConfig baseConfig) {
        SystemConfig brConfig = (SystemConfig) baseConfig;
        List<AccountPo> account = brConfig.getAccount();
        if(account==null){
            throw new BusinessException("账号信息校验不通过");
        }
        for (AccountPo accountPo : account) {
            GetmeltingTokenUtils.getTokenId(accountPo.getUserName(), accountPo.getPassWord(),accountPo.getApicode());
        }
    }
}
